﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Web;
using nanoCMS.Core.Concrete;
using Ninject;


namespace nanoCMS.Core.Membership.Attributes {
	public class UniqueEmailAttribute : ValidationAttribute{

		[Inject]
		public WorldContext WorldContext { get; set; }

		public override bool IsValid(object value) {
			if (value == null) return true;
			
			return WorldContext.UserProvider.IsEmailInUse(value.ToString());
		}
	}
}
